home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
UUCP
/
UUX.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-03
|
43KB
|
1,224 lines
/*--------------------------------------------------------------------*/
/* u u x . c */
/* */
/* Queue remote commands for UUCP under UUPC/extended */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by */
/* the UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: uux.c 1.8 1993/10/03 20:43:08 ahd Exp $
*
* Revision history:
* $Log: uux.c $
* Revision 1.8 1993/10/03 20:43:08 ahd
* Normalize comments to C++ double slash
*
* Revision 1.7 1993/10/01 01:17:44 ahd
* Additional correct from Richard Gumpertz
*
* Revision 1.6 1993/09/28 01:38:19 ahd
* Corrections from Robert H. Gumpertz (rhg@cps.com)
*
* Revision 1.5 1993/09/20 04:48:25 ahd
* TCP/IP support from Dave Watt
* 't' protocol support
* OS/2 2.x support (BC++ 1.0 for OS/2)
*
*/
/*
Program: uux.c 27 August 1991
Author: Mitch Mitchell
Email: mitch@harlie.lonestar.org
Much of this code is shamelessly taken from extant code in
UUPC/Extended.
Usage: uux [ options ] command-string
Where [ options ] are:
-aname Use name as the user identification replacing the initiator
user-id. (Notification will be returned to the user.)
-b Return whatever standard input was provided to the uux command
if the exit status is non-zero.
-c Do not copy local file to the spool directory for transfer to
the remote machine (default).
-C Force the copy of local files to the spool directory for
transfer.
-e Remote system should use sh to execute commands.
-E Remote system should use exec to execute commands.
-ggrade Grade is a single letter/number; lower ASCII sequence
characters will cause the job to be transmitted earlier during
a particular conversation.
-j Output the jobid ASCII string on the standard output which is
the job identification. This job identification can be used by
uustat to obtain the status or terminate a job.
-n Do not notify the user if the command fails.
-p The standard input to uux is made the standard input to the
command-string.
-r Do not start the file transfer, just queue the job.
(Currently uux does not attempt to start the transfer
regardless of the presense of this option).
-sfile Report status of the transfer in file.
-xdebug_level
Produce debugging output on the standard output. The
debug_level is a number between 0 and ??; higher numbers give
more detailed information.
-z Send success notification to the user.
The command-string is made up of one or more arguments that
look like a normal command line, except that the command and
filenames may be prefixed by system-name!. A null
system-name is interpreted as the local system.
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <io.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _Windows
#include <windows.h>
#endif
/*--------------------------------------------------------------------*/
/* Local include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "hlib.h"
#include "getopt.h"
#include "getseq.h"
#include "expath.h"
#include "import.h"
#include "pushpop.h"
#include "security.h"
#include "hostable.h"
#include "timestmp.h"
#ifdef _Windows
#include "winutil.h"
#include "logger.h"
#endif
/*--------------------------------------------------------------------*/
/* Define current file name for panic() and printerr() */
/*--------------------------------------------------------------------*/
currentfile();
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
typedef enum {
FLG_USE_USERID,
FLG_OUTPUT_JOBID,
FLG_READ_STDIN,
FLG_QUEUE_ONLY,
FLG_NOTIFY_SUCCESS,
FLG_NONOTIFY_FAIL,
FLG_COPY_SPOOL,
FLG_RETURN_STDIN,
FLG_STATUS_FILE,
FLG_USE_EXEC,
FLG_MAXIMUM
} UuxFlags;
typedef enum {
DATA_FILE = 0, // Normal data file passed argument
INPUT_FILE = 1, // Redirected stdin file
OUTPUT_FILE = 2 // Redirected stdout file
} FileType;
static boolean flags[FLG_MAXIMUM] = {
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE
};
static char* st_out = NULL;
static char* user_id = NULL;
static char grade = 'Z'; // Default grade of service
static char job_id[15];
static char* spool_fmt = SPOOLFMT;
static char* dataf_fmt = DATAFFMT;
static char* send_cmd = "S %s %s %s - %s 0666\n";
/*--------------------------------------------------------------------*/
/* Internal prototypes */
/*--------------------------------------------------------------------*/
void main(int argc, char **argv);
static void usage( void );
static char *SwapSlash(char *p);
static boolean cp(char *from, char *to);
static boolean split_path(char *path,
char *system,
char *file,
boolean expand,
char *default_sys);
static boolean CopyData( const char *input, const char *output);
static boolean do_uuxqt(char *job_name, char *src_syst, char *src_file, char *dest_syst, char *dest_file);
static boolean do_copy(char *src_syst, char *src_file, char *dest_syst, char *dest_file);
static boolean do_remote(int optind, int argc, char **argv);
static void preamble(FILE* stream);
static char subseq( void );
/*--------------------------------------------------------------------*/
/* u s a g e */
/* */
/* Report flags used by program */
/*--------------------------------------------------------------------*/
static void usage()
{